Skip to content

device: avoid direct assignment to device api pointer #26190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2020

Conversation

pabigot
Copy link
Contributor

@pabigot pabigot commented Jun 15, 2020

Almost all drivers use DEVICE_AND_API_INIT() or a wrapper of that to initialize the device API table pointer. Fix two drivers that assigned to during initialization, and remove documentation that suggests this is appropriate.

There is one remaining case that is fixed by "drivers/gpio: Use DEVICE_AND_API_INIT for mmio32 driver" from #24873, but I believe draft process requires @tbursztyka either submit that independently or explicitly grant me permission to cherry-pick it into this (which I'm willing to do).

pabigot added 3 commits June 15, 2020 08:15
This is set when the device is defined, and should not be modified.

Signed-off-by: Peter Bigot <[email protected]>
This is set when the device is defined, and should not be modified.

Signed-off-by: Peter Bigot <[email protected]>
The driver API should be assigned at the time the device is defined.
Assigning in the init function is redundant and prevents moving the
pointer to a immutable driver structure.

Signed-off-by: Peter Bigot <[email protected]>
Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MaureenHelm MaureenHelm merged commit ccc53f9 into zephyrproject-rtos:master Jun 16, 2020
@pabigot pabigot deleted the nordic/20200615a branch June 16, 2020 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants